package org.dromara.tearoom.dubbo;

import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.tearoom.api.RemoteMqttService;
import org.dromara.tearoom.service.ITerIotDeviceOperLogService;
import org.dromara.tearoom.service.ITerIotDeviceService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * Mqtt服务实现类
 */
@RequiredArgsConstructor
@Service
@DubboService
public class RemoteMqttServiceImpl implements RemoteMqttService {

    private final ITerIotDeviceService terIotDeviceService;

    private final ITerIotDeviceOperLogService terIotDeviceOperLogService;

    /**
     * 刷新GeeOpen设备状态
     */
    @Override
    public void refreshGeeOpenDeviceInfo() {
        terIotDeviceService.refreshAllDeviceInfo();
    }

    /**
     * 清除设备3天前日志
     */
    @Override
    public void cleanDeviceLog() {
        terIotDeviceOperLogService.deleteBatchByTime(LocalDateTime.now().minusDays(3));
    }
}
